<?php
namespace app\member\model;
use think\Model;
class Member extends Model
{

 
    public function login($data){
        $admin=Member::getByMobile($data['username']);
        $member=$this->getOne($data['username']);
        if($admin){
            if($admin['password']==$data['password']){
                session('id', $admin['id']);
                session('mobile', $admin['mobile']);
                session('username',$member['username']);
                session('vip',$member['vip']);
                return 2; //登录密码正确的情况
            }else{
                return 3; //登录密码错误
            }
        }else{
            return 1; //用户不存在的情况
        }

    }



    public function getOne($mobile){
        $member=$this::field('*')->where(array('mobile'=>$mobile))->find();
        return $member;
    }






}
